Baraj Constanta, august 1997
Problema 1 (Agricultura - Petru Pau)
Dificultate: D2

	In satul Valea lui Liman a ajuns legea reformei agrare. Fiecare satean
s-a repezit sa caute in sertare sau poduri documente vechi, ramase de la batrani,
pentru a cere cat mai mult pamant.
	Comisia de stribuire a pamntului este formata din primar si .. atat.
Caci sunt putini oameni ramasi in sat, si de unde sa aleaga alti membri ?..
	Primarul a cerut satenilor sa-si prezinte in scris pretentiile. Dupa
doua zile, cererile taranilor erau asezate vraf pe biroul primarului.
	Fiecare familie a cerut un singur lot, dreptunghiular. Toate loturile 
au laturile paralele intre ele. Primarul a primit de la fiecare satean coordonatele
colturilor opuse ale lotului cerut.
	Oameni intelepti, satenii au evitat sa includa in loturi zonele mlastinoase,
acestea fiind portiuni de teren inconjurate complet de loturi, nesolicitate de 
nimeni.
	Fapt interesant, desi pot exista zone revendicate de mai multi sateni
(si care apartin deci de mai multe loturi), singurele zone agricole ale satului 
nerevendicate sunt cele mlastinoase.

	Figura cu doua mlastini, ambele in zona de loturi din stanga

Problema:
	Scrieti un program care determina cate astfel de portiuni mlastinoase
se afla in zona satului Valea lui Liman.
Intrare:
	Datele de intrare se gasesc intr-un fisier al carui nume se citeste de
la tastatura. Structura unui fisier de date este:
n		- numarul de loturi solicitate de sateni (1<=n<=200);
a1 b1 c1 d1	- (a1,b1) si (c1,d1) sunt coordonatele colutrilor opuse ale
		lotului din prima cerere
......
an bn cn dn	- (an,bn) si (cn,dn) sunt coordonatele colturilor opuse ale
		lotului din a n-a cerere.
Toate coordonatele sunt numere reale pozitive, iar laturile loturilor sunt
paralele cu axele de coordonate.
	In plus, daca (x1,y1) si (z1,u1) sunt doua varfuri oarecare din doua
loturi diferite, atunci x1<>z1 si y1<>u1.
Iesire:
	Se scrie pe ecran un singur numar intreg k, reprezentand numarul
zonelor mlastinoase din zona satului.
Exemplu:
Pentru intrarea:
5
0.0 0.0 10.1 1.1
0.2 2.0 10.0 3.2
10.4 5.3 0.1 4.3
0.3 0.1 1.0 5.0
10.2 5.1 9.6 0.3
programul va afisa
2

Timp de executie: 1 secunda per test.
==============================
Solutia 1 (Petru Pau)
uses graph, crt, dos;
const  infty = 20000000;
nr_max_drept = 500;

type
  DIRECTION = (UP, DOWN, ZERO);
  punct = record
            x, y : real;
          end;
  dreptunghi = record
            NV, SE : punct;
               end;

  pMuchie = ^muchie;
  muchie = record
             x, y1, y2: real;
             used     : boolean;
             next     : pMuchie;
             points   : DIRECTION;
           end;
var
  D     : array[1..nr_max_drept] of dreptunghi;
  nr_d,
  nr_y  : word;
  events: array[1..nr_max_drept * 2 + 1] of record
                 x: real;
                 tip: (inceput, sfirsit);
                 b, t: real
               end;
  l_stat: array[1..nr_max_drept * 2] of record
            y: real;
            nr_supra: word;
          end;
  V     : pMuchie;
  nV    : integer;
  xmin, xmax,
  ymin, ymax,
  rx, ry : real;
  shift_left, shift_up: integer;
  NrMlast : integer;
  TEST  : boolean;
  leftmost : muchie;
  ora, min, sec, ss: word;
  ora1, min1, sec1, ss1: word;

procedure switch(var a, b: real);
var aux: real;
begin
  aux:=a; a:=b; b:=aux
end;

procedure pSwitch ( A, B: pMuchie);
begin
  switch(A^.x,  B^.x);
  switch(A^.y1, B^.y1);
  switch(A^.y2, B^.y2);
end;

procedure InsOrd(x, y1, y2: real; d: DIRECTION; var L : pMuchie);
var p, aux: pMuchie;
begin
  new(aux);
  aux^.x  := x;
  aux^.y1 := y1;
  aux^.y2 := y2;
  aux^.used   := false;
  aux^.points := d;

  if L = nil then
   begin
     L := aux;
     L^.next := nil;
   end
  else
   begin
     p := L;
     if (y1<p^.y1) or ((y1=p^.y1) and (x<p^.x)) then
      begin
        aux^.next := L;
        L         := aux;
      end
     else
      begin
        while (not ((y1<p^.next^.y1) or
              ((y1=p^.next^.y1) and (x<p^.next^.x)))) and
              (p^.next<>nil) do
          p:=p^.next;
        if p^.next=nil then
         begin
           aux^.next := nil;
           p^.next := aux
         end
        else
         begin
           aux^.next := p^.next;
           p^.next   := aux;
         end;
      end;
   end;
end;

procedure Delete(p: pMuchie; var L: pMuchie);
var q: pMuchie;
begin
  if p = L then
   begin
     L := L^.next;
     dispose(p)
   end
  else
   begin
     q := L;
     while q^.next <> p do q := q^.next;
     q^.next := q^.next^.next;
     dispose(p)
   end;
end;

procedure ReadDrept;
var s: string;
    f: text;
begin
  ClrSCr;
  Write('Introduceti numele fisierului din care citesc dreptunghiurile ');
  ReadLn(s);

  gettime(ora, min, sec, ss);
  assign(f, s);
  reset(f);
  nr_d := 0;
  while not eof(f) do
   begin
     inc(nr_d);
     with D[nr_d] do
      begin
       ReadLn(f, NV.x, NV.y, SE.x, SE.y);
       if NV.x > SE.x then switch(NV.x, SE.x);
       if NV.y < SE.y then switch(NV.y, SE.y);
      end;
   end;
end;

procedure bubble;
var i: integer;
    k: boolean;
begin
  repeat
    k:=true;
    for i:=1 to 2 * nr_d - 1 do
     if (events[i].x < events[i+1].x) or
        ((events[i].x=events[i+1].x) and
         (events[i].tip<=events[i+1].tip)) then
     else
      begin
        k:=false;
        events[2 * nr_max_drept + 1] := events[i];
        events[i]:=events[i+1];
        events[i+1]:=events[2 * nr_max_drept + 1]
      end;
    until k
end;

procedure CreateEvents;
var i: word;
begin
  for i:=1 to nr_d do
   begin
     with events[2*(i-1) + 1] do
      begin
        x   := D[i].NV.x;
        tip := inceput;
        b   := D[i].SE.y;
        t   := D[i].NV.y
      end;
     with events[2*(i-1) + 2] do
      begin
        x   := D[i].SE.x;
        tip := sfirsit;
        b   := D[i].SE.y;
        t   := D[i].NV.y
      end;
   end;
  bubble
end;

procedure CreateStatus;
var i:word;

procedure BinSort;
type  key = real;
      ref = ^nod;
      nod = record
              info  : key;
              Fs, Fd: ref
            end;
var a: ref;
    x: key;
    i: integer;
procedure insert(var a: ref; k: key);
begin
  if a=nil then
   begin
     new(a);
     a^.fs:=nil;
     a^.fd:=nil;
     a^.info:=k
   end
  else
   if k<a^.info then insert(a^.fs, k)
   else if k>a^.info then insert(a^.fd,k);
end;
procedure crearb(var a: ref);
var x: key;
    var i:word;
begin
  a:=nil;
  for i:=1 to 2 * nr_d do
    insert(a,l_stat[i].y);
end;
procedure parcurg(var a:ref);
begin
    if a<>nil then
   begin
    if a^.fs<>nil then parcurg(a^.fs);
    inc(i);
    l_stat[i].y := a^.info;
    if a^.fd<>nil then parcurg(a^.fd)
   end
end;
begin
  a:=nil;
  crearb(a);
  i:=0;
  parcurg(a);
  nr_y := i
end; { BINSORT }

begin
  for i := 1 to nr_d do
    begin
      with l_stat[2 * (i - 1) + 1] do
       begin
          y := D[i].SE.y;
          nr_supra := 0;
       end;
      with l_stat[2 * (i - 1) + 2] do
       begin
          y := D[i].NV.y;
          nr_supra := 0;
       end;
    end;
  BinSort
end;

{***********  That's it! ***************}

procedure Sweep;
var i : word;
    yB, yE: real;
    y1, y2: real;

procedure AdInterval(x, b, t: real);
var k, k1, k2: integer;
begin

  k  := 1;
  while l_stat[k].y < b do inc(k);
  k1 := k;
  while l_stat[k].y < t do inc(k);
  k2 := k;
  k  := k1;

  repeat
    while (k<k2) and (l_stat[k].nr_supra > 0) do inc(k);
    if k<k2 then
     begin
       inc(nV);
       y1 := l_stat[k].y;
       while (k<k2) and (l_stat[k].nr_supra = 0) do inc(k);
       y2 := l_stat[k].y;
       InsOrd(x, y2, y1, DOWN, V);
    end
  until k >= k2;

  for k:=k1 to k2-1 do
   inc(l_stat[k].nr_supra);
end;
procedure DelInterval(x, b, t: real);
var k, k1, k2: integer;
    y1, y2: real;
begin
  k  := 1;
  while l_stat[k].y < b do inc(k);
  k1 := k;
  while l_stat[k].y < t do inc(k);
  k2 := k;
  k  := k1;

  for k:=k1 to k2-1 do
   dec(l_stat[k].nr_supra);

  k := k1;
  repeat
    while (k<k2) and (l_stat[k].nr_supra > 0) do inc(k);
    if k<k2 then
     begin
       inc(nV);
       y1 := l_stat[k].y;
       while (k<k2) and (l_stat[k].nr_supra = 0) do inc(k);
       y2 := l_stat[k].y;
       InsOrd(x, y1, y2, UP, V);
     end
  until k = k2;

end;
var s:string;
begin
  nV := 0;
  V := nil;
  AdInterval(events[1].x, events[1].b, events[1].t);

  for i:=2 to 2 * nr_d do
   begin
     if events[i].tip = inceput then
       AdInterval(events[i].x, events[i].b, events[i].t)
     else
       DelInterval(events[i].x, events[i].b, events[i].t);
   end;
end;

procedure Count;
var i, j, k, iMin,treceri: integer;
    gata: boolean;
    c : char;
    VD, p, aux: pMuchie;
    xNext, yNext1, yNext2,
    yIni1, yIni2, xIni : real;
    f: text;
    s: string;
begin
  p := V;
  new(VD);
  VD^ := V^;
  VD^.next := nil;
  switch(VD^.y1, VD^.y2);

  p := V^.next;
  while p<>nil do
   begin
     new(aux);
     aux^      :=p^;
     aux^.next := VD;
     VD        := aux;
     switch(VD^.y1, VD^.y2);
     p         := p^.next;
   end;

   p := VD;
   while p<>nil do
    begin
      InsOrd(p^.x, p^.y1, p^.y2, p^.points, V);
      p := p^.next
    end;

  p := V;
  while p<>nil do
   begin
     new(aux);
     aux^.next := p^.next;
     aux^.x := p^.y1;
     aux^.y1 := p^.x;
     aux^.y2 := p^.next^.x;
     aux^.points := ZERO;

     p^.next := aux;
     p := p^.next^.next^.next;
   end;

   NrMlast := 0;
   repeat
     p := V;
     xIni  := p^.x;
     yIni1 := p^.y1;
     yIni2 := p^.y2;

     leftmost := p^;

     xNext  := p^.next^.next^.x;
     yNext1 := p^.next^.next^.y2;
     yNext2 := p^.next^.next^.y1;

     Delete (p, V);
     p := V;

     Delete (p, V);
     p := V;
     if leftmost.x > p^.x then
       leftmost := p^;

     Delete(p, V);
     gata := false;
     p := V;
     repeat
       if p=nil then p:=V;
       treceri := 0;
       while not(((p^.y1 = yNext1) and
                  (p^.y2 = yNext2) and
                  (p^.x = xNext))                 or
                 ((p^.next^.next^.y1 = yNext1) and
                  (p^.next^.next^.y2 = yNext2) and
                  (p^.next^.next^.x  = xNext)))
         and (treceri<2) do
        if p^.next^.next^.next = nil then
           begin
             p:=V;
             inc(treceri);
           end
         else p:=p^.next^.next^.next;
       if treceri<2 then
        begin
          if leftmost.x > p^.x then
           leftmost := p^;

          aux := p^.next;
          if ((p^.y1 = yNext1) and
              (p^.y2 = yNext2) and
              (p^.x = xNext))
           then
            begin
              xNext  := p^.next^.next^.x;
              yNext1 := p^.next^.next^.y2;
              yNext2 := p^.next^.next^.y1;
            end
           else
            begin
              xNext  := p^.x;
              yNext1 := p^.y2;
              yNext2 := p^.y1;
            end;

          Delete (p, V);
          p := aux;

          aux := p^.next;

          Delete (p, V);
          p := aux;
          if leftmost.x > p^.x then
            leftmost := p^;

          aux := p^.next;

          Delete(p, V);
          p := aux;
        end;
     until (xNext = xIni) and
           (yNext1 = yIni1) and
           (yNext2 = yIni2) ;
     if leftmost.points=UP then
      begin
        inc(NrMlast);
      end;
   until V = nil;
end;

begin
  TEST := true;
  randomize;
  ReadDrept;
  CreateEvents;
  CreateStatus;
  Sweep;
  Count;
  gettime(ora1, min1, sec1, ss1);
  GotoxY(34,12);
  if NrMlast>1 then
    Write('Au fost ',NrMlast,' mlastini.')
  else
   if NrMlast = 1 then
     Write('A fost o mlastina.')
   else WriteLn('N-a fost nici o mlastina.');
 writeln;
 writeln;
 writeln(ora, ':', min, ':',sec,',', ss);
 writeln(ora1, ':', min1, ':',sec1,',', ss1);
  readln;
end.
---------------------------
Solutia 2 (Stroe Mihai)
{$A+,B-,D+,E+,F-,G-,I+,L+,N-,O-,P-,Q-,R-,S+,T-,V+,X+,Y+}
{$M 65520,0,655360}

const
  Max = 410;

type
  List = array[1..Max] of Real;

procedure QuickSort(var A: List; Lo, Hi: Integer);

   procedure Sort(l, r: Integer);
     var
     i, j : integer;
     x, y : real;
     begin
       i := l; j := r; x := a[(l+r) DIV 2];
       repeat
         while a[i] < x do inc(i);
         while x < a[j] do dec(j);
         if i <= j then
            begin
              y := a[i]; a[i] := a[j]; a[j] := y;
              inc(i); dec(j);
            end;
         until i > j;
         if l < j then Sort(l, j);
         if i < r then Sort(i, r);
     end;

begin {QuickSort};
  Sort(Lo,Hi);
end;


type ar=array[1..410]of byte;
     arr=array[1..32767]of word;
     ref=^ar;
var fi,fo:text;
    s:string;
    i,j,k,l,m,n:longint;
    d:array[1..200,1..4]of real;
    a:array[1..410]of ref;
    x,y:list;
    t:real;
    st,en:word;
    cx,cy:^arr;

procedure readdata;
begin
  x[1]:=-1;
  y[1]:=-1;
  readln(fi,n);
  for i:=1 to n do
      begin
        readln(fi,d[i,1],d[i,2],d[i,3],d[i,4]);
        if d[i,1]>d[i,3] then
           begin
             t:=d[i,1];
             d[i,1]:=d[i,3];
             d[i,3]:=t;
           end;
        if d[i,2]>d[i,4] then
           begin
             t:=d[i,2];
             d[i,2]:=d[i,4];
             d[i,4]:=t;
           end;
        x[i * 2]:=d[i,1];
        x[i * 2+1]:=d[i,3];
        y[i * 2]:=d[i,2];
        y[i * 2+1]:=d[i,4];
      end;
end;

procedure umple(var k:longint);
var x1,y1,x2,y2,i,j:word;
begin
  x1:=1;
  while x[x1]<>d[k,1] do inc(x1);
  x2:=x1+1;
  while x[x2]<>d[k,3] do inc(x2);
  y1:=1;
  while y[y1]<>d[k,2] do inc(y1);
  y2:=y1+1;
  while y[y2]<>d[k,4] do inc(y2);
  for i:=x1 to x2-1 do
      for j:=y1 to y2-1 do
          a[i]^[j]:=1;
end;

function min(i,j:longint):longint;
begin
  if i>j then min:=j else min:=i;
end;

procedure fill(x,y:word);
var i:longint;
begin
  cx^[1]:=x;
  cy^[1]:=y;
  st:=1;
  en:=1;
  a[cx^[1]]^[cy^[1]]:=1;

  while st<=en do
    begin
      if a[cx^[st]+1]^[cy^[st]]=0 then
         if cx^[st]+1<=m then
            begin
              inc(en);
              cx^[en]:=cx^[st]+1;
              cy^[en]:=cy^[st];
              a[cx^[en]]^[cy^[en]]:=1;
            end;
      if a[cx^[st]-1]^[cy^[st]]=0 then
         if cx^[st]-1>0 then
            begin
              inc(en);
              cx^[en]:=cx^[st]-1;
              cy^[en]:=cy^[st];
              a[cx^[en]]^[cy^[en]]:=1;
            end;
      if a[cx^[st]]^[cy^[st]+1]=0 then
         if cy^[st]+1<=m then
            begin
              inc(en);
              cx^[en]:=cx^[st];
              cy^[en]:=cy^[st]+1;
              a[cx^[en]]^[cy^[en]]:=1;
            end;
      if a[cx^[st]]^[cy^[st]-1]=0 then
         if cy^[st]-1>0 then
            begin
              inc(en);
              cx^[en]:=cx^[st];
              cy^[en]:=cy^[st]-1;
              a[cx^[en]]^[cy^[en]]:=1;
            end;
      inc(st);
      if en>32700 then
         begin
           for i:=1 to min(st,en-st+1) do
               begin
                 cx^[i]:=cx^[en];
                 cy^[i]:=cy^[en];
                 dec(en);
               end;
           st:=1;
           en:=i;
         end;
    end;
end;

procedure solve;
begin
  new(cx);
  new(cy);
  quicksort(x,1,2*n+1);
  x[2*n+2]:=x[2*n+1]+1;
  quicksort(y,1,2*n+1);
  y[2*n+2]:=y[2*n+1]+1;
  m:=2*n+2;
  for i:=1 to m do
      begin
        new(a[i]);
        fillchar(a[i]^,sizeof(a[i]^),0);
      end;
  for i:=1 to n do
      umple(i);
  k:=0;
  for i:=1 to m do
      for j:=1 to m do
          if a[i]^[j]=0 then
             begin
               fill(i,j);
               inc(k);
             end;
  writeln(k-1);
end;

begin
  assign(fi,'mlastina.dat');
  reset(fi);
  readdata;
  solve;
  close(fi);
end.
=================================
	TESTE INTRARE
test 1
7
0 0 10 1
0.1 2 10.1 3
0.2 4 10.2 5
0.3 6 10.3 7
0.4 8 10.4 9
0.5 10 10.5 11
4 0.1 6 11.1
------------------------
Test 2:
4
0   0   5   1
0.1 0.1 1   5
4   0.2 4.9 4.9
0.2 4.1 4.8 4.8
-------------------------
test 3:
17
0    0.01 10    1
0.01 2    10.01 3
0.02 4    10.02 5
0.03 6    10.03 7
0.04 8    10.04 9
0.05 10   10.05 11
4    0.02 5.01  11.01
0.06 0.03 1     11.02
2    0.04 3     11.03
6    0.05 7     11.04
8    0.06 9     11.05
10   0.07 11    11.06
0.07 0.08 1.01  5.01
2.01 0.09 3.01  5.02
6.01 0.1  7.01  5.03
0.08 4.01 5.02  5.04
5    6.01 10.06 7.01
-------------------------------
test 4:
164
 11.000  25.000 194.000  91.000
147.000  69.000 306.000 143.000
257.000 126.000 395.000 182.000
354.000 165.000 485.000 215.000
 10.000 126.938 125.000 154.000
 81.000 147.000 175.000 182.748
143.000 173.000 235.000 199.000
194.256 188.000 295.000 226.000
261.000 211.000 339.000 241.000
308.000 231.000 441.000 279.000
458.000 207.000 551.000 244.000
474.000 235.000 503.000 296.000
360.000 291.000 499.000 305.000
288.000 290.000 381.000 316.000
219.000 248.000 296.000 299.000
169.000 238.000 231.000 259.000
 84.000 198.000 134.000 223.000
 23.000 171.000  59.000 191.000
 30.000 183.000  58.000 248.345
 41.000 237.000  95.000 285.000
 71.000 275.000 132.000 340.000
111.000 327.000 174.000 369.000
148.000 360.000 222.000 400.000
186.000 391.000 273.000 430.000
150.000 281.000 209.000 307.000
181.000 295.000 216.000 329.000
193.000 322.000 246.000 349.000
225.000 339.000 293.000 366.000
265.000 349.976 347.000 382.000
321.000 369.215 436.000 410.000
346.000 330.000 429.000 352.000
460.000 333.000 552.000 370.000
517.000 356.000 567.000 380.000
467.000 365.000 534.000 407.000
513.000 391.829 564.000 421.000
478.000 417.000 536.000 442.000
512.000 432.000 556.000 458.000
486.000 453.000 531.000 469.000
339.104  34.000 623.000  27.000
567.545  30.000 601.000  62.000
583.000  53.000 615.000  83.000
601.601  78.000 632.000 108.000
613.000 100.000 639.000 124.000
513.646  32.000 549.000  55.000
528.000  46.000 551.861  72.000
540.000  69.802 558.000  85.000
549.522  78.572 571.000  96.000
564.212  92.000 581.000 114.000
577.000 110.000 603.000 134.000
460.482  29.000 484.000  50.000
472.000  48.000 491.000  66.000
486.415  64.000 502.000  82.000
495.000  79.000 513.723  97.000
504.000  92.132 522.000 110.445
508.000 103.000 515.000 112.000
520.000 108.079 541.000 135.000
532.000 130.000 569.000 154.240
552.751 145.000 583.767 168.000
567.100 161.000 609.000 185.000
594.000 181.000 629.000 206.000
615.001 202.000 639.273 218.000
597.000 216.000 623.687 225.000
582.000 223.291 603.392 237.383
576.000 234.000 594.802 247.000
571.484 245.000 589.000 263.000
571.158 260.000 590.000 281.498
576.536 274.000 617.000 301.000
600.000 295.945 634.000 312.000
619.000 310.000 639.613 323.000
348.000  32.409 379.000  48.953
366.000  43.000 401.000  60.000
380.000  54.000 416.000  71.000
387.000  65.000 432.000  85.149
410.000  78.524 453.000  97.672
441.712  94.000 470.000 111.000
454.000 107.000 478.572 123.000
460.607 116.000 482.000 132.000
473.000 127.000 496.000 145.675
482.323 142.000 501.000 157.000
494.000 154.205 515.864 170.000
507.000 167.000 530.000 180.000
519.000 178.000 544.000 190.000
535.000 188.727 563.000 198.013
554.000 196.000 572.000 206.482
560.000 205.000 570.000 218.279
556.959 218.517 570.168 226.331
220.000  13.000 297.000  36.000
277.000  33.000 314.000  47.000
305.000  43.675 324.000  55.212
316.000  55.238 334.000  67.000
327.000  66.627 347.466  81.000
333.000  78.142 359.000  93.000
345.000  89.000 371.000 102.000
356.000  99.000 384.000 108.098
376.000 106.000 401.026 116.986
397.000 111.868 415.000 121.000
408.000 120.000 425.000 128.000
419.000 126.435 436.180 137.000
429.057 136.000 444.000 144.000
439.000 143.115 453.224 153.000
515.972 257.000 532.653 270.000
521.000 267.000 545.000 278.000
530.046 277.000 545.511 284.000
538.000 283.000 550.000 293.000
543.000 290.843 555.000 300.000
549.626 298.000 561.000 313.000
555.124 310.964 566.000 321.000
563.659 320.000 577.692 329.457
575.000 329.642 593.000 340.849
589.823 339.227 601.155 347.000
598.000 347.043 615.501 359.000
611.000 357.000 628.000 370.046
585.000 374.000 600.295 389.000
592.000 386.000 614.000 398.000
607.000 397.000 626.000 409.000
618.000 408.000 633.000 419.000
579.000 415.000 598.320 427.000
591.000 423.000 613.167 439.000
604.000 436.000 623.802 449.000
619.728 449.007 637.000 461.000
566.311 448.000 589.124 461.206
576.625 459.000 600.718 472.000
300.000 420.000 331.000 434.000
318.000 432.688 353.000 443.000
339.352 442.208 371.843 453.489
358.000 452.000 389.000 462.000
375.000 460.000 402.000 470.000
 30.133 358.000  48.000 369.264
 42.000 366.753  65.000 382.167
 52.000 376.000  81.868 392.000
 62.000 387.000  89.000 401.000
 74.000 398.408 113.000 417.567
 64.000 411.000  82.000 420.845
 54.000 419.664  81.687 428.000
 46.000 424.000  65.019 433.000
 39.000 432.693  37.000 439.908
 37.314 439.088  29.000 437.000
 28.000 437.651  28.000 437.645
 25.000 430.632  56.000 443.786
 17.000 438.000  43.000 451.000
 34.000 448.610  64.697 467.000
 50.000 465.000  95.961 478.000
 82.136 476.000  96.000 479.000
 82.438 455.000 106.000 465.450
 92.000 449.833 111.972 459.438
102.000 443.091 122.000 449.738
111.371 436.139 130.000 441.000
116.000 429.000 139.000 437.360
125.814 422.000 144.000 430.969
128.000 417.388 144.755 424.196
123.000 404.000 136.000 411.409
130.973 407.458 145.000 418.000
121.000 396.000 133.000 403.000
115.000 386.702 132.298 395.000
102.190 379.000 120.000 387.206
 94.000 372.000 105.000 381.000
 82.815 362.000  98.000 372.760
 72.000 356.647  87.000 364.000
 61.000 351.000  80.000 356.585
 56.440 345.000  66.000 354.000
 44.000 340.210  61.463 350.000
 31.000 334.000  44.035 343.000
 24.000 327.632  40.000 335.000
 33.000 323.937  44.570 329.947
-------------------------------
test 5:
109
 14.000   2.000 235.000  25.000
 15.000  16.000  36.000  48.000
 15.905  39.000  41.000  59.000
 19.000  53.000  51.000  70.000
  3.000  65.000  45.000  81.000
 23.000  77.000  72.000  93.000
 51.599  35.000  82.000  43.000
 68.000  41.000  93.000  50.000
 77.000  48.055  99.000  60.000
 88.000  57.000 111.000  71.000
 63.000  83.000 116.000 106.000
 91.000  66.000 117.000  89.000
108.000  80.000 202.000 122.000
221.000  20.000 258.000  53.972
167.000  43.945 243.000  83.109
319.000   0.000 623.000  17.000
286.000   8.000 331.000  27.000
302.000  20.915 328.000  43.195
310.000  40.000 366.000  59.260
358.000  53.702 409.000  76.000
382.000  70.130 393.000  88.000
366.271  91.000 366.420  91.000
366.475  89.575 392.000 100.000
342.000  87.000 366.843 107.000
321.000  98.000 358.213 124.000
284.000  90.000 335.000 120.000
272.000 107.808 299.000 139.000
279.000 128.000 315.000 155.000
307.000 149.000 356.000 165.000
344.000 142.000 370.000 157.000
362.000 135.000 388.000 146.000
379.000 121.000 398.000 141.000
394.000 113.000 413.000 126.000
407.000 109.000 417.000 114.000
410.000 104.000 422.000 110.000
378.000  27.717 404.000  36.000
396.000  33.000 414.000  39.294
404.987  36.924 431.000  47.000
425.000  44.000 446.000  52.000
439.000  51.000 448.000  63.000
434.000  60.299 450.000  77.468
424.000  71.626 444.000  88.348
420.000  84.000 430.000  97.000
410.187  95.000 434.271 109.712
 22.000 154.000 310.510 176.000
  6.000 170.000  35.000 457.000
 22.804 450.000 631.000 462.000
612.000  13.000 639.000 452.000
 49.000 189.000 290.000 210.000
 51.771 204.000  61.000 404.000
 55.000 402.000 305.000 424.000
282.000 196.000 307.953 410.000
 66.000 220.000  81.000 378.000
 72.979 227.000 250.000 236.000
244.001 228.000 268.000 384.000
 74.000 367.000 255.000 381.000
 91.125 246.000 228.000 255.000
 95.000 251.000 107.000 275.000
100.000 272.000 122.000 295.000
111.072 291.000 135.000 306.000
119.000 303.000 149.000 318.000
136.000 318.543 147.000 333.000
118.000 333.662 136.977 335.000
102.000 334.000 125.000 345.000
129.000 328.000 157.000 344.000
151.000 342.000 169.000 347.000
150.000 274.000 178.000 291.523
166.000 288.000 184.000 303.684
166.522 302.000 190.000 327.000
170.000 324.000 184.424 335.206
165.000 335.466 179.000 345.826
201.000 257.000 228.350 279.000
214.000 277.000 218.000 294.000
202.891 293.000 222.000 305.000
202.999 303.816 222.913 323.000
211.000 319.000 226.000 333.501
176.000 331.000 225.000 342.459
550.000  39.907 582.000  55.000
524.000  34.000 558.000  45.000
506.000  35.365 526.000  46.000
493.000  37.000 516.000  50.443
484.000  41.005 507.000  60.990
473.000  53.285 504.000  75.000
474.000  71.811 503.000  96.000
466.000  87.136 502.000 109.731
459.000 104.686 486.000 121.334
487.000 107.405 518.000 115.000
510.000  97.716 542.000 111.000
524.285  85.000 562.000 106.821
548.000  76.284 566.000  89.040
555.000  70.914 570.000  78.000
558.236  50.974 566.922  71.105
332.000 182.000 351.000 423.000
366.287 181.000 387.000 423.743
407.839 151.000 421.000 413.000
438.000 138.000 470.000 405.000
482.000 131.000 506.060 420.000
519.000 128.982 543.000 413.985
557.000 125.000 583.000 424.055
399.000 156.000 587.000 180.000
451.000 124.150 571.000 144.000
342.359 186.000 573.000 209.000
340.000 221.000 567.000 248.000
345.000 263.000 572.000 285.000
346.000 299.000 573.660 310.000
343.000 325.000 554.000 343.000
339.000 358.000 567.448 367.264
343.920 383.000 563.000 393.000
343.363 408.000 568.000 414.000
-------------------------------------
test 6:
159
  0.000   0.000 639.000  15.000
639.072  15.749 639.596  15.936
623.000   4.000 631.000 479.000
  0.019 466.000 639.046 478.000
  0.864 474.000  21.000  12.000
 10.000 206.000 107.000 232.000
159.000 240.000 242.000 251.000
 98.000 223.000 172.000 248.000
 33.000  99.000  55.000 195.000
 52.000 191.000 153.000 197.000
138.000 171.000 159.601 192.000
 74.000 164.000 147.000 177.000
114.000 156.000 119.000 166.000
145.000 125.000 147.027 151.000
 93.000 132.000 151.000 138.000
 75.000 107.000 101.000 134.000
 39.000  79.000  57.000 104.000
 47.000  83.000 124.000  96.000
103.000  73.000 116.000  86.000
 39.422  61.000 108.000  73.466
 27.000  31.000  55.132  62.000
 33.176  20.000 192.000  35.000
189.000  31.309 208.000  49.000
 97.000  42.000 193.000  49.088
113.000  47.000 143.000  57.000
133.000  55.000 322.000  79.697
139.000  79.863 190.000  98.000
128.000 101.000 249.000 119.000
172.343  91.000 198.000 104.180
156.000 114.000 249.025 147.000
140.000 139.000 166.000 149.000
186.000 145.000 229.000 179.000
154.000 165.000 199.000 179.203
181.000 196.000 266.000 241.000
240.000 179.182 255.000 200.000
270.000 100.000 434.000 187.000
290.000 177.370 343.000 213.000
341.000  27.000 395.000 102.000
229.262  31.838 359.000  40.000
391.000  30.000 471.000  41.000
457.000  38.000 463.000  52.000
425.000  66.000 433.000 105.000
429.000  86.462 459.000  87.000
426.000 153.000 537.000 144.000
484.000  11.000 510.000 129.000
455.000 107.980 476.000 149.209
524.000  86.863 548.000 152.000
544.000 100.469 576.000 104.882
557.000  40.127 583.000 103.000
519.000  10.000 540.000  69.000
580.000  61.481 610.000  76.000
598.000  70.000 604.000 142.000
566.000 127.000 604.638 141.000
565.000 134.749 579.000 200.548
598.292 165.608 607.000 233.000
466.000 168.000 575.000 180.000
508.000 195.157 574.000 202.000
453.000 167.000 475.000 248.073
359.015 206.437 463.460 221.000
286.000 228.000 376.000 297.000
362.000 217.000 382.000 240.522
 53.000 271.000 222.000 315.000
187.000 302.000 277.000 336.000
 64.000 309.000 126.000 431.000
 29.000 323.000  40.000 430.000
 37.000 410.000  70.000 420.000
 47.186 368.000  56.000 413.000
121.000 378.000 234.000 393.000
146.000 335.000 179.000 361.000
172.652 354.000 189.118 380.000
240.979 356.000 334.000 407.000
208.058 389.000 258.000 406.000
264.000 288.000 305.000 307.000
396.000 267.000 472.000 290.000
437.000 284.000 488.000 297.562
469.000 293.000 509.000 307.880
489.000 304.000 529.000 318.000
511.000 316.000 552.000 333.000
530.000 330.000 567.000 345.000
554.000 341.000 589.000 360.000
573.000 355.000 609.000 376.000
490.000 254.000 537.009 275.000
513.000 265.000 556.000 282.000
537.284 276.000 573.184 293.629
559.000 288.024 589.802 304.528
577.000 301.000 606.000 315.903
588.000 312.000 614.000 329.000
347.000 309.114 408.000 326.000
371.000 318.434 429.857 333.276
404.000 331.000 450.000 347.000
426.822 343.000 473.000 360.892
444.000 356.799 493.000 371.000
472.280 368.671 514.000 381.000
492.000 379.000 535.000 395.000
520.000 391.000 565.115 410.015
541.000 406.101 590.000 421.000
564.000 417.000 603.000 430.956
584.000 429.000 622.000 446.000
608.000 441.000 626.000 454.000
294.000 329.526 332.000 339.000
326.000 337.000 356.000 345.785
347.159 343.573 387.000 359.000
366.000 356.253 411.000 372.000
384.000 368.284 432.000 387.000
414.000 386.000 459.823 409.000
438.000 406.962 484.102 424.000
458.000 420.877 508.068 439.000
482.000 437.000 528.000 450.000
510.615 448.000 547.000 454.158
351.000 398.000 386.000 414.000
372.000 410.535 402.000 427.000
391.392 426.000 427.000 442.000
413.000 440.000 439.000 451.000
426.947 450.416 458.791 467.000
367.000 272.000 425.227 284.774
606.193 323.850 627.000 337.700
286.228 402.000 311.000 421.036
296.000 417.814 330.000 431.074
316.000 429.887 347.409 442.589
341.773 442.408 365.000 449.000
233.000 417.928 251.000 425.000
247.000 424.707 272.000 438.000
261.000 435.000 283.000 452.000
273.000 447.000 308.000 469.000
145.016 408.000 178.000 423.000
165.000 421.983 187.345 433.000
176.000 430.780 207.000 442.776
195.000 438.788 221.000 450.638
209.000 449.060 243.000 468.000
 89.000 426.324 109.000 439.185
101.063 437.665 130.000 449.785
120.000 447.126 147.557 455.000
490.689 217.404 523.000 224.000
472.904 209.000 495.000 218.000
512.000 221.955 528.860 228.468
522.000 228.379 541.891 234.000
537.398 233.486 560.000 241.037
551.000 240.745 573.650 250.000
567.615 250.219 590.292 260.000
581.000 258.000 596.000 267.813
590.515 267.150 612.000 276.747
395.245 246.000 412.000 254.801
404.473 251.234 423.000 258.483
410.000 256.000 410.000 256.000
410.519 255.000 448.000 273.000
406.000 221.041 422.000 234.471
258.871 256.929 276.000 260.204
264.535 257.000 292.000 268.000
214.000 265.629 235.000 274.000
226.000 271.370 244.000 281.000
235.559 277.000 252.000 287.000
245.000 284.390 254.000 293.619
  3.000 230.000  31.000 243.000
 17.000 238.000  37.879 246.063
 33.982 244.000  51.000 252.000
 42.000 250.888  68.000 257.729
 77.000 250.985  87.000 259.000
 82.000 256.428  95.000 262.000
 89.019 261.000 111.000 275.135
--------------------------------------
test 7:
108
   0.000 473.569 628.224 455.667
   0.001 444.726 630.936 425.898
   0.002 412.252 627.132 399.107
   5.940 386.182 627.233 369.542
  11.887 358.391 616.820 341.674
  15.840 330.984 607.971 309.870
  24.761 300.082 594.174 280.385
   9.905 268.480  36.655   5.941
  47.535 264.560  75.286   8.914
  85.174 259.511 116.888  16.845
 129.788 257.621 154.559  24.752
 160.440 258.534 176.323  27.731
 182.208 271.361 230.894  31.712
 236.651 267.313 260.525  38.632
 286.168 252.544 299.991  46.535
 321.935 240.645 332.966  54.485
 348.621 228.697 377.255  62.420
 383.215 226.886 427.091  69.336
 459.657 219.809 492.264  75.262
 504.047 218.834 524.870  78.265
 553.941 471.483 610.099   2.971
 343.815  53.509 567.705  25.755
  18.824 108.959 563.452  60.403
  17.823  39.639 297.282   8.914
 294.205  31.702 367.568  14.862
 274.468 145.633 315.944 126.762
 339.628 131.691 362.483 116.934
 422.013 128.817 461.629 113.905
 488.366 143.628 556.807 121.832
 535.617 125.783 549.517 111.943
 499.409 128.778 507.023 113.925
 264.594 142.656 267.397 114.842
 266.329 152.471 280.249 130.745
  41.582 133.677  56.462 115.838
  30.696 163.436 208.968 140.687
  23.773 284.236 351.461 216.023
 270.297 217.866 280.195 166.357
 265.500 191.080 273.433 180.229
 109.891 201.076 134.764 180.295
 122.880 216.895 132.671 208.076
  77.295 215.853  98.065 183.198
  27.724 199.135  41.597 178.281
 303.936 170.295 310.058 138.730
 306.003 198.076 327.756 164.448
 310.957 216.900 315.928 191.203
 433.708 234.803 447.530 157.542
 411.211 222.874 441.656 196.022
 396.100 269.324 403.932 220.000
 357.513 251.630 562.434 239.708
 468.417 267.357 494.294 257.408
  29.711 467.747 118.868 278.305
 153.504 344.760 169.434 334.830
 196.022 355.500 221.845 291.116
 263.569 459.787 282.295 351.656
 186.250 425.782 200.127 382.244
 131.689 474.684 153.486 361.678
 360.440 401.997 407.149 330.961
 436.744 384.170 449.601 342.637
 470.478 350.672 486.154 308.126
 521.925 405.937 527.090 339.645
 293.327 443.950 310.095 354.467
 349.668 453.695 362.589 432.932
 379.227 427.779 392.072 418.012
 440.630 420.159 457.731 408.049
 473.507 417.148 488.139 378.211
 494.399 456.611 523.922 415.045
 427.117 286.283 450.655 257.449
 444.631 263.438 457.777 246.562
 485.541 286.243 502.351 261.376
 517.265 267.370 531.144 250.526
 525.897 262.533 547.686 257.559
 537.630 283.154 544.940 261.547
 528.874 217.987 542.975 175.400
 535.043 203.102 559.469 186.139
 533.615 160.524 544.511 141.646
 537.635 178.265 552.459 156.540
 532.862 245.627 548.006 211.013
 512.975 224.937 520.850 214.852
 472.697 229.889 478.204 215.021
 486.517 228.782 498.267 214.919
 492.283 237.823 502.239 223.862
 497.191 243.771 513.188 229.694
 454.456 245.689 469.568 228.750
 366.385 286.367 388.245 260.475
 369.360 265.400 380.252 245.716
 338.816 189.105 354.767 166.349
   0.000 460.545  14.863 343.669
 390.296  46.534 419.947   0.000
 445.851  63.404 470.364   9.910
 477.276  16.840 494.220   1.981
 488.208  36.646 521.003   7.924
 452.462  12.880 480.169   0.000
 411.199  15.845 457.629   2.971
 436.960 149.609 465.446 138.622
 392.385 313.855 430.998 292.307
 264.501 317.861 314.074 292.165
 319.099 346.654 349.579 323.907
 326.858 374.519 346.657 351.525
 315.816 402.273 328.697 384.147
 216.889 391.425 237.626 378.230
 235.801 362.479 247.660 352.643
 171.301 376.432 190.245 351.684
 214.960 427.680 254.510 420.023
 181.271 448.882 212.863 440.915
 229.886 462.479 253.499 437.885
 422.867 456.413 430.863 448.529
 443.628 462.741 460.401 437.713
 318.105 462.442 337.897 433.734
-----------------------------------
test 8:
200
 46.000 332.000 131.000 332.000
283.000 155.000 340.000 162.000
162.000 238.000 170.000 279.000
156.000 310.000 217.000 319.000
307.000 222.000 316.000 317.000
 58.000  86.000  59.000 118.000
385.000 112.000 386.000 122.000
256.000 283.000 326.000 289.000
377.000 136.000 380.000 218.000
247.000 184.000 248.000 191.000
151.000 227.000 155.000 274.000
351.000 335.000 358.000 340.000
193.000  42.000 201.000  69.000
366.000 195.000 394.000 199.000
129.000 130.000 136.000 130.000
 17.000 168.000  25.000 169.000
 30.000 229.000  37.000 293.000
259.000 117.000 259.000 154.000
  8.000 340.771  44.000 345.000
286.000 256.000 292.000 354.000
175.000  96.000 184.000 133.000
106.000  75.000 115.000 170.000
173.000 108.000 176.000 118.156
 41.000 218.519  76.000 220.000
140.000 322.000 140.000 339.000
370.000 111.000 457.000 116.000
203.000 318.000 210.000 357.000
220.000 261.000 229.000 339.418
 62.000 298.000 104.000 299.000
 43.000 191.840 127.000 193.000
351.925 309.000 359.000 337.000
122.000 130.659 122.000 216.000
302.000  56.000 304.000 126.000
368.000 251.000 368.000 336.000
357.000 193.673 359.839 213.000
301.000  41.000 315.000  49.000
388.000 181.000 392.000 253.000
 59.663  49.969  68.000 130.793
307.427 399.000 308.000 401.000
 77.000 100.000 173.208 105.000
 13.000  43.000  39.000  49.261
197.000 373.000 199.000 461.000
 23.000 206.000 111.000 210.000
238.000 287.000 239.000 356.000
233.000 261.702 236.000 358.000
337.000 252.000 390.000 253.800
 54.000 296.000  62.976 366.000
 39.172 311.000  43.458 343.000
327.000  98.000 381.000  99.000
 35.000 246.000 123.000 251.827
 51.000 244.000  55.000 283.282
182.000 212.000 185.000 311.879
150.000 243.000 158.000 263.000
339.000  34.000 388.943  42.657
168.000  11.000 170.390  87.000
383.000  16.000 468.000  20.000
 34.000 179.000  40.000 191.891
111.384 313.000 164.000 319.172
 69.000 290.000  69.000 370.000
210.608  51.000 233.417  56.310
 61.000 176.000  69.284 184.999
 38.000  71.000 117.000  80.000
350.000 145.000 435.000 147.000
 23.295  85.000  25.712 167.000
240.000 166.000 294.000 168.970
277.000 180.000 277.000 254.000
 33.000 251.510  36.000 274.584
 39.108 133.390  78.000 133.660
349.000 163.000 353.000 245.000
 23.610 176.313  24.000 181.983
350.142  41.539 437.000  43.238
260.000  85.533 350.010  93.000
217.244 233.000 239.954 240.000
384.000 132.000 392.650 209.000
 10.000 300.000  26.000 300.000
  1.000 191.605  41.144 196.000
  8.065 131.000  49.000 140.000
187.000 272.000 187.000 279.104
 68.007  18.000  75.000  40.000
269.000 134.000 276.000 177.000
135.000 339.004 149.000 343.147
321.000 154.174 384.800 154.620
361.000 333.000 375.000 334.000
379.000 330.000 422.000 331.000
103.000 260.000 103.000 263.441
211.000 395.000 216.000 456.000
220.788 178.000 229.311 226.000
 85.000  12.000 132.000  17.000
178.000 180.987 183.000 197.000
 11.000  86.996  19.000 177.005
162.682 158.000 197.720 159.000
105.000 132.961 113.000 195.988
399.000  71.047 456.000  72.000
224.000 369.000 228.000 425.000
 53.000 169.840  57.000 206.864
399.541 182.000 406.000 202.000
 23.756 193.619  26.659 241.000
 33.241  54.000 109.000  58.000
168.242 160.000 172.000 222.294
238.842 273.000 239.649 326.000
 83.000 226.915 157.000 235.000
212.000 311.929 289.000 313.469
298.000  50.000 310.000  57.000
329.000 154.377 332.000 190.000
148.000  91.000 204.000 100.282
240.673  78.000 268.000  86.864
 31.000 295.000  89.000 295.000
160.000 298.122 161.000 360.000
 29.000  86.525  94.000  92.000
 44.746 380.000  52.000 460.000
 95.000 275.000 148.446 275.000
107.000 153.000 140.957 154.403
360.000  84.000 402.000  93.380
263.000  16.739 299.000  25.000
344.000 142.000 353.069 156.000
 15.000 187.000  92.000 189.000
100.000 273.165 176.874 278.000
258.000  13.000 262.000  33.000
127.030 345.777 128.000 353.000
375.412 190.495 382.000 226.106
122.705 127.000 129.659 159.977
171.000 347.000 183.572 350.000
159.000 326.881 160.280 335.374
296.000 121.000 300.000 159.952
342.000  55.000 351.723 141.000
267.000 273.450 355.000 275.731
 34.931 264.000  72.000 272.886
365.000  83.000 370.216  97.000
227.000 371.000 320.000 378.000
384.888  58.156 389.000  86.469
211.175 215.000 241.000 222.986
168.993 175.000 174.000 263.132
 47.000 313.038 138.000 317.412
100.080  27.000 179.000  30.000
 54.772  35.000  56.000  51.419
 78.484 275.830  82.000 360.378
 99.000 263.191 198.000 270.000
253.000 189.361 302.950 190.701
248.172  63.000 255.000 158.650
 96.000 225.000 148.396 229.782
248.229  68.000 251.000 119.000
203.337  30.138 211.602  59.000
 76.161  24.000  83.223 101.000
128.161 132.710 137.000 160.977
287.000 304.000 359.286 310.836
304.479  59.204 312.000 132.312
 84.000 285.000  93.000 354.693
287.492 206.608 337.557 211.000
254.000 225.196 317.000 227.259
344.324 311.552 428.000 316.000
 75.648 114.000 173.696 121.107
243.000 325.000 244.000 350.462
345.000 330.471 386.971 334.995
377.302 161.000 442.000 168.122
 58.104 386.000  62.791 455.000
 54.600 247.000 124.000 247.000
210.213 230.000 302.811 233.920
319.000 263.422 373.000 271.000
 50.000 263.105  50.000 311.224
393.000 223.000 401.000 316.335
 44.020 214.000  52.186 248.000
 46.201  95.000  53.297 130.106
 64.000 113.000  66.000 159.339
398.000 271.534 404.000 338.000
 42.000 319.866 135.350 322.583
128.295  74.000 223.000  83.946
272.000 345.159 307.526 352.000
102.000 391.000 200.000 399.203
230.000 345.036 235.000 420.000
196.000 208.000 202.000 232.000
313.000 288.000 316.992 347.585
280.000 399.100 332.386 400.000
297.000 333.875 299.465 405.000
257.000 358.978 260.245 406.000
242.000 197.808 243.606 244.037
205.000 323.000 205.000 418.000
166.000 238.681 227.649 242.000
112.000  99.345 121.000 108.482
162.324 325.396 233.725 333.871
194.000   5.000 279.000  13.314
272.631 232.692 276.773 283.306
272.553 219.000 273.000 299.961
155.828 235.002 159.740 303.000
 91.000 143.000 107.674 143.000
145.000 389.000 152.000 410.000
169.000  46.000 171.578 102.000
124.331 367.000 125.000 410.830
313.584  41.280 406.174  47.000
206.000 351.000 283.778 354.636
309.000 384.000 347.000 393.000
226.000 173.000 237.000 175.305
 40.059  65.000  44.869 136.808
 35.903 243.536  92.885 246.167
328.000  15.000 349.302  23.000
365.819  35.747 366.083 130.564
342.199  16.217 385.554  20.587
 24.666 147.825  24.302 209.523
189.000 397.000 190.000 404.000
143.000 356.306 150.656 410.399
189.357 270.593 198.330 322.407
---------------------------------
test 9:
200
407.000   0.000 463.000   4.000
444.000   1.000 478.000  12.000
468.000   8.000 505.000  24.000
485.000  19.000 529.000  32.000
507.000  26.000 550.000  42.000
533.000  38.000 571.000  51.000
554.000  46.000 590.000  61.000
572.000  56.000 620.000  77.000
601.000  70.000 639.000  86.000
622.000  83.000 639.681  91.000
288.000   0.068 353.000  11.000
335.000   6.000 368.000  21.000
355.000  18.000 385.000  32.797
374.000  27.000 405.000  42.323
391.000  37.000 443.000  54.000
415.000  48.000 461.000  65.000
441.000  57.000 489.000  74.000
459.000  68.000 505.313  86.049
482.000  79.000 528.000  95.000
505.622  88.000 547.000 108.000
529.711 103.000 572.861 119.000
546.000 111.000 587.000 128.000
567.000 123.000 608.000 136.000
595.000 133.000 621.000 143.000
611.000 141.000 639.466 151.000
629.000 150.000 639.769 154.000
194.000   0.619 218.000  13.000
210.000   7.000 240.000  25.000
232.000  20.000 259.000  36.000
250.000  32.355 275.000  47.000
266.000  43.000 300.000  60.000
290.000  56.994 320.000  73.000
306.000  67.000 342.000  87.000
331.000  82.000 364.000 101.000
348.000  95.193 382.000 115.000
366.000 109.000 402.000 130.000
380.000 123.497 422.000 145.000
410.000 139.000 448.000 159.000
435.000 155.000 464.000 170.000
452.000 167.000 488.000 186.000
479.000 182.000 512.000 201.000
491.000 195.000 528.342 214.000
510.000 208.000 547.573 231.000
529.682 223.000 574.000 246.000
554.414 241.000 594.000 259.000
576.000 255.000 614.000 277.000
600.000 273.000 628.000 288.000
615.000 284.000 639.022 301.000
 94.000   0.894 141.000  25.194
125.000  18.649 162.000  42.902
145.000  36.904 174.000  55.000
162.245  51.185 195.000  71.000
186.000  66.000 219.000  88.861
202.000  81.000 235.000 101.608
224.000  98.000 257.000 120.000
244.000 114.000 282.000 134.000
272.000 128.160 299.000 147.000
285.000 139.408 316.000 163.000
298.000 154.874 334.000 176.000
317.000 170.390 354.000 189.000
344.000 183.000 373.000 207.000
352.000 199.000 386.000 219.000
371.000 210.000 404.000 230.000
388.000 224.000 424.000 246.854
412.000 235.000 438.000 256.000
425.000 250.000 452.811 268.000
442.000 262.000 474.000 282.000
458.000 275.000 490.000 292.000
476.000 286.000 508.000 306.000
496.000 300.000 525.000 319.000
514.000 313.000 539.000 330.000
526.000 326.000 561.000 346.000
547.113 339.000 579.000 357.000
564.000 351.000 599.000 375.000
582.000 368.000 615.298 385.000
603.000 380.000 636.000 400.000
615.013 394.000 639.580 412.000
  5.000   0.698  26.000  15.000
 13.000   8.492  39.000  23.000
 26.186  17.000  59.000  35.000
 49.000  30.000  80.000  51.985
 72.000  47.602  98.000  63.000
 83.000  56.139 116.000  74.227
 99.000  67.076 127.000  86.913
115.000  79.189 142.000  99.000
130.000  94.000 151.000 110.000
139.000 105.000 163.000 122.000
153.000 116.000 182.000 139.128
173.000 136.544 196.000 158.000
184.000 154.671 219.794 177.000
207.000 169.000 244.285 197.000
222.000 187.000 263.000 210.061
241.000 196.000 273.000 219.629
257.319 210.965 298.711 235.383
276.000 228.000 313.000 249.000
303.000 244.000 328.000 263.000
325.000 264.000 352.894 280.000
338.000 275.430 361.000 289.000
311.000 253.000 341.000 274.000
352.218 283.000 376.000 300.414
365.000 297.000 398.000 321.000
389.000 316.000 414.000 335.000
402.925 328.000 427.000 348.000
412.234 339.119 441.595 358.000
426.000 351.498 462.000 372.000
442.486 365.000 474.995 384.000
456.000 378.000 486.000 395.000
470.000 389.000 499.000 408.000
488.562 404.000 522.000 423.000
505.120 415.000 537.000 435.000
510.600 423.321 548.000 442.000
536.000 439.000 562.000 459.000
548.413 452.000 580.000 470.000
565.000 466.000 586.000 479.000
  0.000  45.000  23.000  70.630
 13.704  64.000  40.000  85.000
 30.000  79.448  65.000 103.530
 54.000  99.335  81.000 121.000
 75.000 117.000  88.000 138.000
 80.233 135.000 101.000 153.000
 93.000 149.000 123.000 169.797
112.000 163.669 132.000 184.000
123.807 179.000 148.000 202.000
139.864 196.150 167.000 217.000
158.000 210.310 183.000 228.846
162.470 214.864 190.000 235.292
177.000 231.962 204.000 251.000
192.000 245.000 213.000 263.148
209.000 257.000 221.000 272.000
216.000 269.000 238.000 284.234
227.000 280.822 242.000 293.000
234.000 289.731 238.746 295.000
241.944 291.000 282.329 319.771
262.000 311.000 299.747 332.000
232.214 286.220 248.000 301.795
278.000 323.000 319.000 346.925
302.000 340.000 335.123 362.000
322.000 357.332 365.273 378.590
341.539 370.000 375.000 394.297
361.945 388.000 400.000 409.000
384.000 404.696 411.000 428.000
401.000 424.000 426.113 448.000
410.971 440.000 442.542 462.000
426.030 458.000 455.000 478.000
439.000 473.000 454.000 479.736
  0.324 137.000  33.000 166.000
 23.340 157.000  48.000 176.720
 37.000 171.000  65.599 189.243
 54.838 184.216  85.000 203.000
 76.000 201.213 100.000 221.000
 90.000 218.000 120.000 245.965
108.000 242.000 137.000 268.762
126.000 266.000 145.142 285.000
136.000 280.600 162.944 304.000
145.573 296.000 186.711 325.000
171.000 318.000 194.277 342.000
180.000 332.008 221.010 354.000
203.000 350.000 245.000 378.737
229.000 370.680 264.000 392.000
247.000 386.000 286.000 410.000
272.071 402.000 305.000 427.000
289.000 420.000 327.000 446.000
310.000 441.000 345.000 462.136
323.000 454.000 349.000 468.000
335.228 465.000 351.000 479.146
  0.532 196.902  25.000 223.248
 13.830 219.916  59.212 243.000
 38.000 237.000  68.000 261.000
 47.000 254.000  88.945 277.176
 72.835 270.000  99.708 291.004
 85.464 286.894 112.959 305.000
 95.000 300.014 115.236 321.621
107.000 315.000 132.801 335.214
117.000 330.173 143.000 353.000
131.000 346.852 154.000 369.000
141.157 366.000 165.000 384.607
153.509 378.923 179.000 397.000
160.000 387.000 190.515 409.830
175.000 402.137 209.751 424.180
200.000 421.000 225.000 442.693
211.000 437.000 239.000 456.000
227.262 453.000 255.000 469.000
241.877 464.000 259.425 479.213
  0.939 275.690  20.000 295.301
  7.000 291.836  33.119 305.044
 20.825 302.000  44.000 314.000
 30.107 311.614  56.000 326.422
 45.000 323.223  72.158 341.000
 60.000 338.000  84.000 359.000
 63.000 355.000 100.046 391.000
 65.241 381.000 117.918 425.000
626.000  84.000 639.123 168.000
210.144   3.000 353.741  36.014
615.760 284.199 633.000 407.000
 28.000  12.978 120.057  41.000
437.000 450.000 572.392 476.000
  0.600  64.686  43.000 138.390
247.600 457.000 355.794 479.211
  8.000 413.000 111.000 479.083
  0.132 239.197  17.789 310.119 
--------------------------------------
test 10:
74
 3.0000  1.0313  4.8610 101.2025
 6.2729  2.6716  7.3186 102.1617
 9.3722  3.4256 10.0820 103.4747
12.0705  4.8408 13.0597 104.2932
15.9172  5.3679 16.7746 105.3279
18.6976  6.8441 19.7179 106.3066
21.1626  7.3294 22.4660 107.2466
24.8256  8.2790 25.4817 108.1491
27.8743  9.2872 28.7727 109.9764
30.4925 10.8879 31.8272 110.0202
33.1410 11.1435 34.5008 111.0216
36.5929 12.0096 37.7744 112.6506
39.7704 13.7081 40.5575 113.2060
42.6810 14.5928 43.9554 114.6440
45.9983 15.2437 46.6761 115.2956
48.0858 16.7723 49.4952 116.8816
51.5099 17.5733 52.9531 117.6848
54.3387 18.0076 55.7053 118.9889
57.7740 19.7495 58.1977 119.1436
60.9135 20.7841 61.5892 120.8647
63.6893 21.2878 64.0936 121.6289
66.2800 22.8771 67.1612 122.2731
69.5436 23.9607 70.1743 123.1570
72.2681 24.1774 73.5767 124.4981
75.2851 25.1559 76.6097 125.7396
78.7464 26.0803 79.0763 126.0597
81.1065 27.7955 82.8058 127.3816
84.6120 28.4368 85.7408 128.4939
87.3412 29.8188 88.8170 129.1413
90.0934 30.0671 91.0602 130.1939
93.6729 31.2274 94.5703 131.2544
96.3658 32.8370 97.3145 132.3148
99.6564 33.6922 100.9029 133.3186
102.4786 34.2964 103.7667 134.7405
105.5519 35.7235 106.4116 135.5420
108.5958 36.8805 109.6689 136.1123
111.4717 37.4036 112.1147 137.0538
 1.5486  3.6734 101.0807  4.9217 
 2.8387  6.6814 102.9270  7.2772 
 3.7008  9.7344 103.4999 10.6637 
 4.1582 12.2300 104.9465 13.3649 
 5.1267 15.9869 105.3062 16.0544 
 6.1019 18.8666 106.5544 19.6971 
 7.1006 21.6688 107.0165 22.3098 
 8.9042 24.5352 108.3270 25.4424 
 9.9006 27.3471 109.3537 28.4878 
10.0715 30.8508 110.7603 31.1803 
11.9228 33.4935 111.1275 34.8923 
12.4032 36.2075 112.8071 37.5874 
13.1098 39.6232 113.9276 40.5405 
14.3261 42.4483 114.2267 43.1846 
15.6904 45.9960 115.6297 46.6916 
16.5407 48.0972 116.7471 49.1487 
17.2329 51.8803 117.7137 52.4388 
18.9803 54.1544 118.0393 55.1843 
19.0096 57.3788 119.3949 58.3638 
20.0822 60.4538 120.5047 61.4605 
21.6754 63.8175 121.5668 64.2533 
22.3723 66.5826 122.8743 67.6079 
23.2571 69.6969 123.5577 70.8787 
24.3608 72.3639 124.6216 73.7800 
25.4570 75.2053 125.6982 76.8372 
26.7518 78.9018 126.1864 79.7755 
27.2674 81.2954 127.7028 82.4569 
28.9642 84.1884 128.0122 85.2245 
29.8991 87.3228 129.8629 88.7631 
30.9666 90.2743 130.3960 91.8361 
31.0208 93.2469 131.0527 94.5076 
32.4227 96.0003 132.1501 97.7092 
33.3124 99.3953 133.5476 100.2609 
34.1510 102.2929 134.0769 103.7056 
35.3303 105.7892 135.6551 106.5660 
36.8962 108.0217 136.2559 109.8849 
37.6845 111.0323 137.1580 112.1555 
===================================
Program de verificare daca un test este corect construit:
program agricultura;
uses crt;
type interval=record
               inc,sf:real;
               id:integer;
               sel:boolean;
               pus:boolean;
              end;
var a:array[1..200] of record
                        x1,y1,x2,y2:real;
                       end;
    nrnou,lup,nrint,n,nr,pzid:integer;
    pz,minx,miny,maxx,maxy:real;
    nou,int:array[1..200] of interval;

procedure error(x:integer);
 begin
  writeln('Eroare',x);
  halt;
 end;

procedure error1(x:integer;x1:real;i,j:integer);
 begin
  writeln('Eroare',x, ' ',x1:7:3,' in (',i,',',j,')');
  halt;
 end;

procedure citire;
 var f:text;
     i,j:integer;
     tmp:real;
 begin
  assign(f,'mlastina.dat');
  reset(f);
  readln(f,n);
  for i:=1 to n do
   begin
    readln(f,a[i].x1,a[i].y1,a[i].x2,a[i].y2);
    if a[i].x1=a[i].x2 then error1(1,a[i].x1,i,i);
    if a[i].y1=a[i].y2 then error1(2,a[i].y1,i,i);
   end;
  for i:=1 to n-1 do
   for j:=i+1 to n do
    begin
     if a[i].x1=a[j].x1 then error1(3,a[i].x1,i,j);
     if a[i].x1=a[j].x2 then error1(3,a[i].x1,i,j);
     if a[i].x2=a[j].x1 then error1(3,a[i].x2,i,j);
     if a[i].x2=a[j].x2 then error1(3,a[i].x2,i,j);
     if a[i].y1=a[j].y1 then error1(4,a[i].y1,i,j);
     if a[i].y1=a[j].y2 then error1(4,a[i].y1,i,j);
     if a[i].y2=a[j].y1 then error1(4,a[i].y1,i,j);
     if a[i].y2=a[j].y2 then error1(4,a[i].y1,i,j);
    end;
  close(f);
 end;

procedure initializare;
 var i:integer;
 begin
  minx:=a[1].x1;
  maxx:=a[1].x2;
  miny:=a[1].y1;
  maxy:=a[1].y2;
  for i:=2 to n do
   begin
    if minx>a[i].x1 then minx:=a[i].x1;
    if miny>a[i].y1 then miny:=a[i].y1;
    if maxx<a[i].x2 then maxx:=a[i].x2;
    if maxy<a[i].y2 then maxy:=a[i].y2;
   end;
  pz:=miny-1;
  nrint:=1;
  int[1].inc:=minx-1;
  minx:=minx-1;
  int[1].sf:=maxx+1;
  maxx:=maxx+1;
  int[1].sel:=false;
  int[1].id:=1;
  pzid:=2;
 end;

function intre(a,b,c:real):boolean;
 begin
  if (a<=c) and (b>=c) then intre:=true
                       else intre:=false;
 end;

procedure calcul;
 var min,p:real;
     poztemp,j,poztmp,i:integer;
     gasit,pus:boolean;
     tmp,temp:array[1..200,1..2] of real;
 begin
  min:=maxy;
  for i:=1 to n do
   begin
    if (a[i].y1<min) and (a[i].y1>pz) then min:=a[i].y1;
    if (a[i].y2<min) and (a[i].y2>pz) then min:=a[i].y2;
   end;
  pz:=min;
  poztmp:=0;
  for i:=1 to n do
   if (a[i].y1<=pz) and (a[i].y2>pz) then begin
                                           poztmp:=poztmp+1;
                                           tmp[poztmp,1]:=a[i].x1;
                                           tmp[poztmp,2]:=a[i].x2;
                                          end;
  poztemp:=poztmp;
  repeat
   poztmp:=poztemp;
   poztemp:=0;
   for i:=1 to poztmp do
    begin
     pus:=true;
      for j:=i+1 to poztmp do
       begin
        if (tmp[i,1]>tmp[j,1]) and (tmp[i,2]<tmp[j,2]) then pus:=false;
        if (tmp[i,1]<tmp[j,1]) and (tmp[i,2]>tmp[j,2]) then begin
                                                             pus:=false;
                                                             tmp[j]:=tmp[i];
                                                            end;
        if (tmp[i,1]>tmp[j,1]) and (tmp[i,1]<tmp[j,2]) and
           (tmp[i,2]>tmp[j,2]) then begin
                                     pus:=false;
                                     tmp[j,2]:=tmp[i,2];
                                    end;
        if (tmp[i,2]>tmp[j,1]) and (tmp[i,2]<tmp[j,2]) and
           (tmp[i,1]<tmp[j,1]) then begin
                                     pus:=false;
                                     tmp[j,1]:=tmp[i,1];
                                    end;
       end;
     if pus then begin
                  poztemp:=poztemp+1;
                  temp[poztemp]:=tmp[i];
                 end;
    end;
   tmp:=temp;
  until poztemp=poztmp;
  poztmp:=poztemp;
  for i:=1 to poztmp-1 do
   for j:=i+1 to poztmp do
    if tmp[i,1]>tmp[j,1] then begin
                               p:=tmp[i,1];
                               tmp[i,1]:=tmp[j,1];
                               tmp[j,1]:=p;
                               p:=tmp[i,2];
                               tmp[i,2]:=tmp[j,2];
                               tmp[j,2]:=p;
                              end;
  nrnou:=poztmp+1;
  nou[1].sf:=tmp[1,1];
  nou[nrnou].inc:=tmp[poztmp,2];
  nou[1].inc:=minx;
  nou[nrnou].sf:=maxx;
  for i:=1 to poztmp do
   begin
    nou[i].sf:=tmp[i,1];
    nou[i+1].inc:=tmp[i,2];
   end;
  for i:=1 to nrint do int[i].pus:=false;
  for i:=1 to nrnou do
   begin
    gasit:=false;
    nou[i].sel:=true;
    for j:=1 to nrint do
     if intre(int[j].inc,int[j].sf,nou[i].inc) or
        intre(int[j].inc,int[j].sf,nou[i].sf) or
        intre(nou[i].inc,nou[i].sf,int[j].inc) or
        intre(nou[i].inc,nou[i].sf,int[j].sf) then begin
                                                     nou[i].id:=int[j].id;
                                                     int[j].pus:=true;
                                                     nou[i].sel:=nou[i].sel and int[j].sel;
                                                     gasit:=true;
                                                    end;
    if not(gasit) then begin
                        nou[i].id:=pzid;
                        pzid:=pzid+1;
                        if (nou[i].inc<>minx) and (nou[i].sf<>maxx) then nou[i].sel:=true
                                                                    else nou[i].sel:=false;
                       end;
   end;
  for i:=1 to nrint do
   if int[i].pus then
    begin
     for j:=1 to nrint do
      if int[i].id=int[j].id then int[i].pus:=true;
    end
    else begin
          for j:=1 to i-1 do
           if int[i].id=int[j].id then int[j].pus:=true;
         end;
  for i:=1 to nrint do
   if not(int[i].pus) and int[i].sel then nr:=nr+1;
  nrint:=nrnou;
  int:=nou;
 end;

begin
 clrscr;
 citire;
end.